
<div style="clear: both"></div>
<table style="width:100%;text-align: center" id="table" class="layui-table">
        <thead>
        <tr >
            <th  style="text-align: center" nowrap="nowrap">选择</th>
            <th style="text-align: center" nowrap="nowrap">执行人表单类型</th>
            <th  style="text-align: center" nowrap="nowrap">表单变量</th>
        </tr>
        </thead>
        <tbody >
        <tr><td><input type="radio" name="varType" value="1" memo="用户"<#if varType==1>checked="checked" </#if>  ></td>
            <td>用户</td>
            <td><select name="varName" <#if varType!=1 >disabled="disabled"</#if>   >
                <#list userVarList as list>
                    <option value="${list.fieldName}" <#if varName==list.fieldName && varType==1>selected="selected"</#if> >${list.fieldDesc}</option>
                </#list>
                </select>
            </td>
        </tr>
        <tr><td><input type="radio" name="varType" value="2" memo="组织"<#if varType==2>checked="checked" </#if>  ></td>
            <td>组织</td>
            <td><select name="varName" <#if varType!=2 >disabled="disabled"</#if>   >
                <#list orgVarList as list>
                    <option value="${list.fieldName}" <#if varName==list.fieldName && varType==2>selected="selected"</#if> >${list.fieldDesc}</option>
                 </#list>
                </select>
            </td>
        </tr>
    <tr><td><input type="radio" name="varType" value="3" memo="组织负责人"<#if varType==3>checked="checked" </#if>  ></td>
            <td>组织负责人</td>
            <td><select name="varName" <#if varType!=3 >disabled="disabled"</#if>   >
                <#list orgVarList as list>
                    <option value="${list.fieldName}" <#if varName==list.fieldName && varType==3>selected="selected"</#if> >${list.fieldDesc}</option>
                 </#list>
                </select>
            </td>
        </tr>
    <tr><td><input type="radio" name="varType" value="4" memo="角色"<#if varType==4>checked="checked" </#if>  ></td>
            <td>角色</td>
            <td><select name="varName" <#if varType!=4 >disabled="disabled"</#if>   >
                <#list roleVarList as list>
                    <option value="${list.fieldName}" <#if varName==list.fieldName && varType==4>selected="selected"</#if> >${list.fieldDesc}</option>
                 </#list>
                </select>
            </td>
        </tr>
    <tr><td><input type="radio" name="varType" value="5" memo="岗位"<#if varType==5>checked="checked" </#if>  ></td>
            <td>岗位</td>
            <td ><select name="varName" <#if varType!=5 >disabled="disabled"</#if>   >
                <#list posVarList as list>
                    <option value="${list.fieldName}" <#if varName==list.fieldName && varType==5>selected="selected"</#if> >${list.fieldDesc}</option>
                 </#list>
                </select>
            </td>
        </tr>
        <tr><td><input type="radio" name="varType" value="6" memo="普通变量"<#if varType==6>checked="checked" </#if>  ></td>
            <td>普通变量</td>
            <td>
                <select name="userType" <#if varType!=6 >disabled="disabled"</#if>   >
                        <option value="1" <#if userType==1>selected="selected"</#if>>用户</option>
                        <option value="2" <#if userType==2>selected="selected"</#if>>组织</option>
                        <option value="3" <#if userType==3>selected="selected"</#if>>组织负责人</option>
                        <option value="4" <#if userType==4>selected="selected"</#if>>角色</option>
                        <option value="5" <#if userType==5>selected="selected"</#if>>岗位</option>
                </select>
                <select name="varName" <#if varType!=6 >disabled="disabled"</#if>   >
                    <#list otherList as list>
                        <option value="${list.fieldName}" <#if varName==list.fieldName && varType==6>selected="selected"</#if> >${list.fieldDesc}</option>
                     </#list>
                </select>
            </td>
        </tr>

        </tbody>

    </table>
</div>
    <div>
        <input type="hidden" id="nodeId" name="nodeId" value="${nodeId}" />
        <input type="hidden" id="procDefId" name="procDefId" value="${procDefId}"/>
        <input type="hidden" id="modelId" name="modelId" value="${modelId}"/>
        <input type="hidden" id="parentProcDefId" name="parentProcDefId" value="${parentProcDefId}"/>
    </div>
<div class="layui-btn-container" style="text-align: center;position: absolute;bottom: 15px;left: 0px;right: 0px;">
    <button class="layui-btn" lay-submit lay-filter="varForm" id="save">保存</button>
    <button class="layui-btn layui-btn-danger" id="close">关闭</button>
</div>

<script>
    layui.use(['table', 'layer'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var setter = layui.setter;
        var $ = layui.$;

        //编辑权限
        $(document).on('click','[name="varType"]',function () {
            //取消权限，仅限于该弹窗的下拉框
            $("td select[name=varName]").attr("disabled",true);
            $("td select[name=userType]").attr("disabled",true);
            //赋予权限
            $(this).parents("tr").find("select").removeAttr("disabled");
            // $(this).parent().next().next().children().removeAttr("disabled");
        })
        //保存
        $(document).on('click', '#save', function () {
            //获取选中的按钮
            var varTypeName =   $("[name='varType']:checked").attr("memo");
            var varType     =   $("[name='varType']:checked").val();
            var objTr       =   $("input[name='varType']:checked").parents("tr");
            var objSelect   =   $("select[name='varName'] option:selected",objTr);
            var varName     =   objSelect.val();
            var varText     =   objSelect.text();
            var userType,userText;

            if(varType !=6) {
                var hiddenJson =   '{type:' + varType + ',varName:\"' + varName + '\"}';
                var showTxt    =   varTypeName + ",变量名【" + varText + "】";
            } else {
                var userSelect =   $("select[name='userType'] option:selected",objTr);
                userType       =   userSelect.val();
                userText       =   userSelect.text();
                var hiddenJson =   '{type:' + varType +',userType:' + userType +',varName:\"' + varName + '\"}';
                var showTxt    =   varTypeName +",类型【"+userText+"】,变量名【"+varText +"】";
            }

            //对前弹窗文本域赋值
            $(".hiddenJson").html(hiddenJson);
            $(".textarea").html(showTxt);
            //关闭弹窗
            layer.close(layer.index);
            return false;
        });
        //取消
        $(document).on('click', '#close', function () {
            layer.close(layer.index);
        });

    })
</script>
